<!--- begin frm_filter.cfm --->

#l#!--- reference tables ---><cfsilent>
<cfquery name="rsRefQry" dbtype="query">
	SELECT 
		table_name
		, ref_table_name
		, column_name
	FROM
		rsRef
	WHERE
		table_name = <cfqueryparam cfsqltype="cf_sql_varchar" value="#rs.Table_Name#" />
</cfquery>
<cfset lstRefColumn = ValueList(rsRefQry.column_name) />
<cfset lstRefTable = ValueList(rsRefQry.ref_table_name) />
</cfsilent>
<cfloop query="rsRefQry">
#l#cfparam name="attributes.#rsRefQry.column_name#" default="" />
#l#cfinclude template="../#tabName(rsRefQry.ref_table_name)#/qry.cfm" /></cfloop>

#l#cfoutput>
	<form name="frmFilter" id="frmFilter" class="filter" method="get">
		<div>
			<label for="q">
				Search:
			</label>
			<input name="q" id="q" value="##attributes.q##" maxlength="50" size="20" />
		</div>
		
		<cfoutput><cfif ListFind(lstRefColumn,column_name) gt 0>
		<cfsilent>
			<cfscript>
				listPos = ListFind(lstRefColumn,column_name);
				refTable = tabName(ListGetAt(lstRefTable,listPos));
			</cfscript>
		</cfsilent>
		<div>
			<label for="#column_name#">
				#dspFormat(column_name)#:
			</label>
			<select name="#column_name#" id="#column_name#">
				<option value="">-All-</option>
				#l#cfloop query="rs_#refTable#">
				<option value="##rs_#refTable#.#column_name###" #l#cfif attributes.#column_name# eq rs_#refTable#.#column_name#>
					selected#l#/cfif>>#l#cftry>##rs_#refTable#.#Replace(column_name,'_id','_name')####l#cfcatch>#l#cftry>##rs_#refTable#.#Replace(column_name,'_id','_desc')####l#cfcatch>##rs_#refTable#.#column_name####l#/cfcatch>#l#/cftry>#l#/cfcatch>#l#/cftry></option>
				#l#/cfloop>
			</select>
		</div>
		</cfif></cfoutput>
		
		<div>
			<label for="recsPerPage">
				Recs per page:
			</label>
			<select name="recsPerPage" id="recsPerPage">
				#l#cfloop list="#request.lstRecsPerPage#" index="i">
					<option value="##i##" #l#cfif isDefined("attributes.recsPerPage") and i eq attributes.recsPerPage>selected#l#/cfif>>##i##</option>
				#l#/cfloop>
			</select>
		</div>
		
		<div class="actionButtons">
			<input type="submit" value="Search" class="button" />
			<input type="reset" value="Reset" class="button" />
		</div>
		<br clear="all" />
	</form>
#l#/cfoutput>	
<!--- end frm_filter.cfm --->